﻿var express=require("express");
var app=express();
var bodyParser=require("body-parser");

//创建application/x-www-form-urlencoded编码解析
var urlencodedParser=bodyParser.urlencoded({extended:false});

app.use(express.static('public'));

app.get('/index1.html',function(req,resp){
	resp.sendFile(__dirname+"/"+"index1.html");
})

app.post('/process_post',urlencodedParser,function(req,resp){
	//输出json格式
	var response={
		"first_name":req.body.first_name,
		"last_name":req.body.last_name
	}
	console.log(response);
	resp.end(JSON.stringify(response));
})

var server=app.listen(8082,function(){
	console.log("server running at 127.0.0.1:8082");
})